<template>
	<view class="content">
		<u-navbar title="余额明细" :placeholder="true" :autoBack="true" bgColor="rgba(0,0,0,0.0)">
		</u-navbar>
		<view class="item" v-for="(item,index) in list" :key="index">
			<view class="item-left">
				<view class="title">
					{{item.desc}}
				</view>
				<view class="time">
					{{item.time}}
				</view>
			</view>
			<view class="add" v-if="item.price > 0">
				+ {{item.price}}
			</view>
			<view class="reduce" v-else>
				{{item.price}}
			</view>
		</view>
		<u-loadmore :status="status" />
	</view>
</template>

<script>
	export default {
		data(){
			return {
				list:[],
				page:1,
				status: 'loadmore',
			}
		},
		onLoad() {
			this.postlist()
		},
		onReachBottom() {
			this.page = this.page + 1
			this.status = 'loading';
			this.postlist()
		},
		methods:{
			postlist(){
				let params = {
					pageNum: this.page,
					pageSize: 10
				}
				this.$Request({
					method: 'GET',
					url: '/api/member/balance/listRecord',
					data: params,
					ismsg: false,
				}).then(res => {
					console.log(res)
					if (res.code == 200) {
						if (res.rows.length < 10) {
							this.status = 'nomore';
						}
						if (this.page == 1) {
							this.list = res.rows
						} else {
							this.list = [...this.list, ...res.rows]
						}
						console.log(this.list)
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		min-height: calc(100vh - 91rpx);
		background-image: url('../../../static/goods/top-bg.png');
		background-size: 100% 561rpx;
		background-repeat: no-repeat;
		.item {
			margin: 20rpx 20rpx 0 20rpx;
			padding: 20rpx 30rpx;
			border-radius: 20rpx;
			background-color: #fff;
			display: flex;
			align-items: center;
			justify-content: space-between;
			box-shadow: 0px 0px 30px 1px rgba(0,0,0,0.06);
			.item-left {
				.title {
					font-size: 28rpx;
					color: #333;
				}
				.time {
					font-size: 24rpx;
					margin-top: 20rpx;
					color: #999;
				}
			}
			
			.add {
				font-size: 36rpx;
				color: #ff0000;
				font-weight: bold;
			}
			.reduce {
				font-size: 36rpx;
				color: #939393;
				font-weight: bold;
			}
		}
	}
</style>